/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = (appInfo) => {
    /**
     * built-in config
     * @type {Egg.EggAppConfig}
     **/
    const config = (exports = {});

    // use for cookie sign key, should change to your own and keep security
    config.keys = appInfo.name + "test-egg";

    config.host = "localhost";

    config.sequelize = {
        dialect: "mysql",
        database: "system",
        host: config.host,
        port: 3306,
        username: "root",
        password:'root',
        // password: "123456",
        define: {
            timestamps: false, // 添加create,update,delete时间戳
            freezeTableName: true, // 防止修改表名为复数
            underscored: false, // 防止驼峰式字段被默认转为下划线
        },
    };

    config.cluster = {
        listen: {
            port: 7001,
            hostname: "localhost",
        },
    };

    //配置跨域
    config.security = {
        csrf: {
            enable: false,
        },
        domainWhiteList: ["*"],
    };

    // 配置 跨域
    config.cors = {
        credentials: true, // 支持cookie跨域
        // origin: 'http://192.168.0.100:8080', // 这里的地址要配置具体的客户端地址，* 会有问题，另外：如果是App这种，内部使用的file协议，那么file请求接口是不会有跨域问题的
        // origin: "http://127.0.0.1:9528",
        origin:"http://localhost:9528",
        // origin:"http://192.168.3.165:9528",
        credentials:true,
        allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH",
    };

    config.multipart = {
        mode: "file",
        // 文件允许大小
        // fileSize: '3mb',
        whitelist: [".pdf"],
    };

    // add your middleware config here
    config.middleware = [];

    // add your user config here
    const userConfig = {
        // myAppName: 'egg',
    };

    return {
        ...config,
        ...userConfig,
    };
};
